#include <iostream>
#include <vector>
#include <algorithm>  // std::make_heap, std::pop_heap, std::push_heap, std::sort_heap
using namespace std;

int main()
{
    int myints[] = { 10, 20, 30, 5, 15 };
    vector<int> v(myints, myints+5);

    std::make_heap(v.begin(), v.end());
    cout << "initial max heap   : " << v.front() << endl;

    std::pop_heap(v.begin(), v.end()); v.pop_back();
    cout << "max heap after pop : " << v.front() << endl;

    v.push_back(99); std::push_heap(v.begin(), v.end());
    cout << "max heap after push: " << v.front() << endl;

    std::sort_heap(v.begin(), v.end());

    cout << "final sorted range :";
    for (unsigned i = 0; i < v.size(); i++) {
        std::cout << ' ' << v[i];
    }
    cout << endl;
    return 0;
}

